package org.jetlinks.pro.messaging.rabbitmq.command.admin;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import org.jetlinks.core.message.codec.http.HttpUtils;
import org.springframework.http.HttpMethod;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Mono;

@Getter
@Setter
@AllArgsConstructor
public class ClearPermission extends AdminCommand<Mono<Void>> {

    private String username;
    private String vhost;

    @Override
    public String api() {
        String vHost = HttpUtils.urlEncode(getVhost());

        return "/api/permissions/" + vHost + "/" +getUsername();
    }

    @Override
    public HttpMethod method() {
        return HttpMethod.DELETE;
    }

    @Override
    public Mono<Void> convert(WebClient.ResponseSpec responseSpec) {
        return responseSpec.bodyToMono(Void.class);
    }
}
